package com.example.allshengmedical.system.activity;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.R.integer;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.allshengmedical.R;
import com.example.allshengmedical.base.BaseActivity;
import com.example.allshengmedical.mainmenu.activity.MainMenuActivity;
import com.example.allshengmedical.system.presenter.OpticalPresenter;
import com.example.allshengmedical.system.view.IOpticalView;
import com.example.allshengmedical.util.ByAlert;

public class OpticalActivity extends BaseActivity implements IOpticalView,
		OnClickListener {
	OpticalPresenter opticalPresenter;
	RelativeLayout tempAeraLine, LEDAreaLine;
	Button TempcalibrationBtn;
	Button tempAeraBtn;
	Button LEDAreaBtn;

	@Override
	protected int setcontent() {
		// TODO Auto-generated method stub
		return R.layout.activity_optical;
	}

	@Override
	protected void initView() {
		// TODO Auto-generated method stub
		opticalPresenter = new OpticalPresenter(this);
		opticalPresenter.initAppHead();

	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub

	}

	@Override
	public void initAppHead() {
		// TODO Auto-generated method stub
		setActionBar();
		setSystemTime();
	}

	private void setSystemTime() {
		// TODO Auto-generated method stub
		TextView date, fileName;
		date = BindView(R.id.date);
		fileName = BindView(R.id.file_name);

		// 获取系统时间
		SimpleDateFormat sdfDate = new SimpleDateFormat("MM dd,yyyy");
		date.setText(sdfDate.format(new Date()));

		// 文件路径置空
		fileName.setText("");

	}

	private void setActionBar() {
		// TODO Auto-generated method stub
		Button leftfirstBtn, leftsecondBtn;
		TextView title;

		leftfirstBtn = BindView(R.id.leftfirst_btn);
		leftsecondBtn = BindView(R.id.leftsecond_btn);
		title = BindView(R.id.title);

		leftfirstBtn.setVisibility(View.VISIBLE);
		leftfirstBtn.setText(R.string.item_actionbar_back);
		leftsecondBtn.setVisibility(View.VISIBLE);
		leftsecondBtn.setText(R.string.item_actionbar_home);
		title.setText(R.string.maintenanceActivity_other);

		leftfirstBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(OpticalActivity.this,
						MaintenanceActivity.class);
				startActivity(intent);
				finish();

			}
		});
		leftsecondBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(OpticalActivity.this,
						MainMenuActivity.class);
				startActivity(intent);
				finish();
			}
		});
	}

	@Override
	public void tempcalibration() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(OpticalActivity.this,
				TempCalibrationActivity.class);
		startActivity(intent);
	}

	@Override
	public void hotMachineArea() {
		Intent intent = new Intent(OpticalActivity.this,
				HotMachineActivity.class);
		startActivity(intent);

	}

	@Override
	public void LEDArea() {
		Intent intent = new Intent(OpticalActivity.this, LEDAreaActivity.class);
		startActivity(intent);
	}

	@Override
	public void Test1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void Test2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void Test3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tempAeraBtn:
			opticalPresenter.hotMachineArea();
			break;
		case R.id.LEDAreaBtn:
			opticalPresenter.LEDArea();
			break;
		case R.id.TempcalibrationBtn:
			opticalPresenter.tempcalibration();
			break;
		default:
			break;
		}

	}

	@Override
	public void initBottomView() {
		// TODO Auto-generated method stub

	}

}
